package com.datastructure.test.bineryhaspathsum;

public class BinaryHasPathSum {

    public static void main(String[] args) {

    }

    public boolean hasPathSum (TreeNode root, int sum) {
        // write code here
        if(root==null){
            return false;
        }
        if(root.left == null && root.right == null&&root.val== sum){
            return true;
        }
        return (root.left != null && hasPathSum(root.left, sum - root.val))||(root.right != null && hasPathSum(root.right, sum - root.val));
    }
}
class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
}
